package com.chenjie.crud.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chenjie.crud.dto.request.query.StationIdListReq;
import com.chenjie.crud.dto.request.query.StationIdReq;
import com.chenjie.crud.dto.request.query.StationReq;
import com.chenjie.crud.dto.request.query.StationUpdateReq;
import com.chenjie.crud.eo.Station;
import com.chenjie.crud.service.StationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@RequestMapping("/v1/station")
@Api(tags = "StationController", description = "岗位管理")
public class StationController {

    @Resource
    private StationService stationService;

    @PostMapping("/createStation")
    @ApiOperation("新增岗位管理")
    public Long createStation(@RequestBody @Valid StationReq stationReq){
        return stationService.createStation(stationReq);
    }


    @GetMapping("/selectStationByPage")
    @ApiOperation("分页查询岗位")
    public Page<Station> selectStationByPage(StationReq stationReq){
        return stationService.selectStationByPage(stationReq);
    }

    @GetMapping("/selectStation/{id}")
    @ApiOperation("通过id查询岗位")
    public Station selectStation(@PathVariable("id") Long id){
        return stationService.selectStation(id);
    }


    @PatchMapping("/updateStationById")
    @ApiOperation("修改岗位岗位信息")
    public Boolean updateStation(@RequestBody @Valid StationUpdateReq stationUpdateReq){
        return stationService.updateStation(stationUpdateReq);
    }

    @DeleteMapping("/deleteStation")
    @ApiOperation("删除岗位岗位信息")
    public Boolean deleteStation(@RequestBody @Valid StationIdListReq stationIdListReq){
        return stationService.deleteStation(stationIdListReq);
    }



}
